#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;

class Solution {
public:
    int maximizeWin(vector<int>& prizePositions, int k) {
        int n = prizePositions.size();
        int mx = 0, ans = 0;
        for (int left = 0, mid = 0, right = 0; mid < n; ++mid)
        {
            while (right < n && prizePositions[right] - prizePositions[mid] <= k) ++right;
            ans = max(ans, mx + right - mid);
            while (prizePositions[mid] - prizePositions[left] > k) ++left;
            mx = max(mx, mid - left + 1);
        }
        return ans;
    }

    vector<int> findDuplicates(vector<int>& nums) {
        int n = nums.size();
        vector<int> ans;
        for (int i = 0; i < n; ++i)
        {
            int x = abs(nums[i]);
            if (nums[x - 1] > 0) nums[x - 1] *= -1;
            else ans.push_back(x);
        }
        return ans;
    }

    vector<int> _findDuplicates(vector<int>& nums) {
        for (int i = 0; i < nums.size(); ++i)
            while (nums[i] != nums[nums[i] - 1])
                swap(nums[i], nums[nums[i] - 1]);
        vector<int> ans;
        for (int i = 0; i < nums.size(); ++i)
            if (nums[i] - 1 != i)
                ans.push_back(nums[i]);
        return ans;
    }
};